<? 

include("../../core.php5/Grid.class.php");
include("../../core.php5/DB/DataBase.class.php");
include("../../core.php5/GridSource.class.php");
include("../../core.php5/GridPresenter.class.php");
include("../../core.php5/GUI/HtmlLink.class.php");
include("../../core.php5/GUI/HTMLCheckBox.class.php");
include("../../core.php5/GridLinker.class.php");
include "../../core.php5/GridSorter.class.php";
include "../../core.php5/GridSortPage.class.php";
include("../../core.php5/Utilities/Application.class.php");

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript">
//<--
function selectAll(field)
{
	var i=0;
	var obj = document.myform.msgs; //document.getElementById(field);

	//alert(obj.type);
	alert(field.length);
	
	for (i = 0; i < obj.length; i++)
	{
		obj[i].checked = true ;
	}
}

function deselectAll(field)
{
	var i=0;
	var obj = document.getElementById(field);
	
	for (i = 0; i < obj.length; i++)
		obj[i].checked = false ;
}
//  End -->
</script>
</head>

<body>
<form name="myform" id="myform" method="post" action="#" ></form>
	<div id="">
			<h3>Revisi&oacute;n de Mensajes</h3>
		<a href="javascript:;" onClick="post('update/mensajes_aut.php','mensajes')" class="agregar">Autorizar</a> | <a href="javascript:;" onclick="selectAll(document.myform.msgs);" >Seleccionar Todos</a> <a href="javascript:;" onclick="deselectAll(document.msgs[]);" >Deseleccionar Todos</a><br />

		  <?
		  
		  	$order="";
		  	$pag="";
		  	
		  	if(isset($_GET['order']) && $_GET['order']!="") $order=$_GET['order'];
		  	if(isset($_GET['pag']) && $_GET['pag']!="") $pag=$_GET['pag'];
		  	 
			$sql = "SELECT idcontact id,  name Nombre, email Correo, phone Telefono, text Mensaje, CASE status WHEN 0 THEN 'Sin revisar'
				   WHEN 1 THEN 'AUTORIZADO'
				   WHEN 3 THEN 'RECHAZADO' 
        END         Estado FROM contact";	
			$g = new Grid();
			GridDataSource::Fill($g, GridSorter::SortQuery($sql, $order));
			//$a = new htmlLink("../select/userinfo.php?id=","Detalles",0,"?id=","newWindow('../usersinfo.php?id=*','windowTittle')");
			//$b = new htmlLink("javascript:;","Editar",0,"", "get('update/mensajes.php?id=*','content')");
			
			##Generamos un link para eliminar y un checkbox para autorizar en monton
			$c = new htmlLink("javascript:;", "Eliminar", 0, "", "get('delete/mensajes.php?id=*','content'); get('select/mensajes.php','content'); $('#mensajes').empty(); $('#mensajes').show(); desaparece('mensajes'); ");
			$cb = new htmlCheckBox("msgs","","","id");
			
			$links = array($cb,$c);
			
			echo GridSortPage::Render($sql, $links, $order, 25, $pag);
			
			
			#echo $cb->getHtml("r1",1,"1",TRUE);
			#echo get_class($cb);
		?>

	</div>
</body>
</html>